/**
 * Created by Administrator on 2017/3/11.
 */

import com.Dao.ApplicationDao;
import com.Dao.DBAcess;
import com.Dao.RecruitmentDao;
import com.Dao.UserDao;
import com.entity.*;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

public class TestUnit {
    @Test
    public void test(){
        User user=new User();
        user.setPrivilege(1);
        user.setPassword("yqn1314520");
        user.setSuperpassword("350582");
        user.setAccount("a845d103549");
        Userinfo userinfo=new Userinfo();
        userinfo.setAccount("a845d103549");
        userinfo.setAddress("福建");
        userinfo.setBirthday("1995-10-09");
        userinfo.setCellphone("15173165334");
        userinfo.setEducation("本科");
        userinfo.setIdCard("350582199510093271");
        userinfo.setName("颜钦能");
        userinfo.setSex("男");
        ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
        UserDao ud=(UserDao)ac.getBean("UserDao");
        ud.addUser(user,userinfo);
        //System.out.print(ud.getUserInfo("a845103549"));

    }


    @Test
    public void testRecruitment(){
        ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
        Recruitment r=new Recruitment();
//        r.setDateline("2017-4-5");
//        r.setNeednumbers(1);
//        r.setDepartment("测试部");
//        r.setPost("被测试人员");
//        r.setWage(3000);
//        r.setExamtype("B类");
//        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
//        r.setPublishdate(df.format(new Date()).toString());
//        r.setRequirement("女性，学历在本科及以上，年龄在25以上，有无工作经验不限");
//        r.setContent("这是在本省的公务员招聘公告，需要的是一名计算机专业的技术人员");
          RecruitmentDao rd=ac.getBean(RecruitmentDao.class);
//          List list=rd.searchGonggao(1,5);
//        Iterator it=list.iterator();
//        while(it.hasNext()){
//            r=(Recruitment)it.next();
//            System.out.println(r.getExamtype()+" "+r.getContent());
//        }
        System.out.println(rd.searchTotal());
//        rd.addRecruitment(r);
    }
}
